package com.xy.annotaion.handler.aop.interceptor;

import com.xy.annotaion.handler.util.Pointer;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @author Dell
 */
public class TestMethodInterceptor implements MethodInterceptor {

    private int c = 0;

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        try {
            Pointer.lg("(3)");
            Pointer.lg("aop test:MethodInterceptor:");
            Pointer.lg(">>this:", invocation.getThis());
            Pointer.lg(">>method:", invocation.getMethod());
            Pointer.lg(">>arguments:", invocation.getArguments());
            Pointer.lg(">>static part:", invocation.getStaticPart());
            Pointer.lg(invocation);

            Object obj = invocation.proceed();
            Pointer.lg("return value:", obj);
            Pointer.lg(c++);
            return obj;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;

    }
}
